<div class="box">
    <div class="box-header">
        <h3 class="box-title">{if condition="isset($info)"}编辑广告{else/}添加广告{/if}</h3>
    </div>
    
    <div class="box-body">
        <form action="" method="post" class="form-horizontal">
            {if condition="isset($info) && isset($info.id)"}
            <input type="hidden" name="id" value="{$info.id}">
            {/if}
            
            <div class="form-group">
                <label class="col-sm-2 control-label">广告标题</label>
                <div class="col-sm-10">
                    <input type="text" name="title" value="{$info.title ?? ''}" placeholder="请输入广告标题" class="form-control" required>
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-2 control-label">广告位置</label>
                <div class="col-sm-10">
                    <select name="position" class="form-control" required>
                        <option value="">请选择广告位置</option>
                        {volist name="position_options" id="option"}
                        <option value="{$key}" {if condition="isset($info) && $info.position == $key"}selected{/if}>{$option}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-2 control-label">广告图片</label>
                <div class="col-sm-10">
                    {assign name="cover_id" value="$info.cover_id|default='0'" /}
                    {:widget('file/index', ['name' => 'cover_id', 'value' => $cover_id, 'type' => 'img'])}
                    <div class="help-block">
                        <small class="text-muted">请上传单张广告图片，支持jpg、png、gif格式</small>
                    </div>
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-2 control-label">链接地址</label>
                <div class="col-sm-10">
                    <input type="text" name="link_url" value="{$info.link_url ?? ''}" placeholder="请输入链接地址" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-10">
                    <input type="number" name="sort" value="{$info.sort ?? 0}" placeholder="数字越大越靠前" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="status" value="1" {if condition="!isset($info) || $info.status == 1"}checked{/if}> 启用
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="status" value="0" {if condition="isset($info) && $info.status == 0"}checked{/if}> 禁用
                    </label>
                </div>
            </div>
            
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <label>内容</label>
                    <textarea class="form-control textarea_editor" name="content" placeholder="请输入文章内容">{$info['content']|default=''|raw}</textarea>
                    {:widget('editor/index', array('name'=> 'content','value'=> ''))}
                </div>
            </div>
            
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-primary">保存</button>
                    <ob_link><a href="{:url('advertisementList')}" class="btn btn-default">返回</a></ob_link>
                </div>
            </div>
        </form>
    </div>
</div>